package org.hp.intern.test;
import java.lang.*;
import java.io.*;
import org.hp.intern.test.Semaphore;;

public class Producer  implements Runnable {

	//表示放有产品的缓冲区个数
	Semaphore full ;
	//表示可用的缓冲区个数
	Semaphore empty ;
	//表示独占信号量
	Semaphore mutex ;
	public Producer (Semaphore Full, Semaphore Empty , Semaphore Mutex){
		
		full = Full;
		empty = Empty;
		mutex = Mutex;
		
	}
	
	/*public void simulate(){
		
		
		
		
	}*/
	public void run() {
		// TODO Auto-generated method stub
		Product();

	}
	
	void Product(){
		
	 while(true){
			
		empty.acquire();
		mutex.acquire();
		System.out.println("product a new item");
		mutex.release();
		full.release();
		
		}
	}
	
	
	
}
